package com.dragon.app.design.pattern.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class Client {

	public static void main(String[] args) {
		
		Star star = new RealStar();
		ProxyHandler proxyHandler = new ProxyHandler(star);
		
		Star proxyStar = (Star) Proxy.newProxyInstance(ClassLoader.getSystemClassLoader(), new Class[] {Star.class}, proxyHandler);
		
//		Star proxyStar = (Star) Proxy.newProxyInstance(ClassLoader.getSystemClassLoader(), new Class[] { Star.class }, new InvocationHandler() {
//					@Override
//					public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
//						System.out.println("====before invoke====");
//						method.invoke(star, args);
//						System.out.println("====after invoke====");
//						return null;
//					}
//				});
		 
		
		proxyStar.fun1();
		proxyStar.fun2();
		proxyStar.sing();

	}

}
